package com.zhu.ssm.controller;

import com.zhu.ssm.pojo.User;
import com.zhu.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/test")
public class UserTestController {
    @Autowired
    private UserService userService;

    @RequestMapping("/user/{id}")
    public ModelAndView getUser(@PathVariable Long id){
        User user = userService.findUser(id);
        System.out.println(user);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("user",user);
        modelAndView.setViewName("/hello.jsp");
        return modelAndView;
    }
}
